package com.ifonly.aop;

/**
 * @author ifonly
 * @version 1.0 2016-01-13 11:56
 * @since JDK 1.6
 */
public final class Enhancer {

    @SuppressWarnings("unchecked")
    public static <T> T enhance(Class<T> clazz) {
        net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(new Callback());
        return (T) enhancer.create();
    }

    @SuppressWarnings("unchecked")
    public static <T> T enhance(Class<T> clazz, Callback callback) {
        net.sf.cglib.proxy.Enhancer enhancer = new net.sf.cglib.proxy.Enhancer();
        enhancer.setSuperclass(clazz);
        enhancer.setCallback(callback);
        return (T) enhancer.create();
    }

}
